<template>
  <div class="hello">
    <el-container>
      <el-header>
        <div style="float:left">
        <span>新生报到系统后台</span>
        </div>
        <div style="float:right">
          {{ name }},欢迎你
          <el-button type="info" @click="logout()">退出</el-button>
        </div>
        <img src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" style="width:50px;height:50px;margin-top:5px;float:right;margin-right:10px" alt="">
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu 
          class="el-menu-vertical-demo" 
          :router="true" 
          :default-active="activePath">
            <el-menu-item :index="'/helloword'" @click="savaNavStatus('/helloword')">
              <i class="el-icon-menu"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item :index="'/message'" @click="savaNavStatus('/Message')">
              <i class="el-icon-menu"></i>
              <span slot="title">文章管理</span>
            </el-menu-item>
            <el-menu-item :index="'/user'" @click="savaNavStatus('/User')">
              <i class="el-icon-menu"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            <el-menu-item :index="'/dormitory'" @click="savaNavStatus('/Dormitory')">
              <i class="el-icon-menu"></i>
              <span slot="title">宿舍管理</span>
            </el-menu-item>
            <el-menu-item :index="'/matriculate'" @click="savaNavStatus('/Dormitory')">
              <i class="el-icon-menu"></i>
              <span slot="title">录取信息管理</span>
            </el-menu-item>
            <el-menu-item :index="'/newborn'" @click="savaNavStatus('/Dormitory')">
              <i class="el-icon-menu"></i>
              <span slot="title">新生报道管理</span>
            </el-menu-item>
            <el-menu-item :index="'/feedback'" @click="savaNavStatus('/Dormitory')">
              <i class="el-icon-menu"></i>
              <span slot="title">反馈信息管理</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'Index',
  data () {
    return {
      name:localStorage.getItem('username'),
      activePath: '',
      avatar:localStorage.getItem('avatar')
    }
  },
  created(){
    this.activePath = sessionStorage.getItem('activePath')
  },
  mounted(){
    
  },
  methods:{
    logout(){
      sessionStorage.clear()
      this.$router.push('/')
    },
    // toggleCollapse () {
    //   this.isCollapse = !this.isCollapse
    // },
    savaNavStatus (activePath) {
      sessionStorage.setItem('activePath', activePath)
      this.activePath = activePath
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.el-header{
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #adbfd4;
    color: #333;
    height: 670px;
    text-align: left;
    /* line-height: 200px; */
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    /* line-height: 160px; */
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
</style>
